from api.ihrm_Login import IhrmLogin
from common.assertTools import common_assert
import pytest
from common.read_jsondata import read_json_file
from config import BASE_PATH

class TestIhrmLogin(object):
    def setup_class(self):#类之前自动被调用一次 执行
        # 创建实例
        self.ihrm_login = IhrmLogin()
    # 拼接json文件的绝对路径,读取,获得[(),()]格式数据
    file_name = BASE_PATH + "/data/loginData.json"
    res = read_json_file(file_name)

    @pytest.mark.parametrize("desc,json_data,status_code,success,code,message",res)
    # 通用测试方法
    def test1_login_success(self,desc,json_data,status_code,success,code,message):
        resp = self.ihrm_login.login(json_data)
        print(desc,":", resp.json())
        # 调用断言
        common_assert(resp,status_code,success,code,message)

